import utils
from sklearn.ensemble import RandomForestClassifier
import numpy as np
from numpy.random import shuffle

if __name__ == '__main__':
    rf = RandomForestClassifier(n_estimators=7)
    feature,label=utils.read_data()
    index=np.arange(960)
    shuffle(index)
    feature=feature[index]
    label=label[index]
    train=(feature[:720],label[:720])
    test=(feature[720:],label[720:])
    rf.fit(train[0],train[1])
    y_hat=rf.predict(test[0])
    y=test[1]
    cnt=0
    for i in range(240):
        cnt+=1 if np.argmax(y_hat[i])==np.argmax(y[i]) else 0
    print(cnt)

